Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3-4280: implement Save a note in Visit Patient scenario #66

Merged
merged 9 commits into from
Feb 25, 2025

Conversation

Bawanthathilan
Copy link
Collaborator

@Bawanthathilan Bawanthathilan commented Feb 24, 2025

This pull request introduces the following changes to enhance the Save a note in Visit Patient scenario:

  • The Save a note in Visit Patient scenario is updated.
  • addVisitNote action is implemented in the DoctorRegistry.java file.
  • Relevant HTTP requests for Save a visit note are added to the DoctorHttpService.java file.

Ticket URL: https://openmrs.atlassian.net/browse/O3-4280

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Member

@jayasanka-sack jayasanka-sack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Bawanthathilan! Just a few minor comments—please take a look. Regarding the test failures, it looks like the End Visit endpoint is returning a 400, which isn't related to this PR. I'll check it out, but feel free to look into it as well if you can.

Comment on lines 150 to 152
return exec(
httpService.saveVisitNote(patientUuid, currentUserUuid, visitNoteText)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation looks a bit weird.

}


public HttpRequestActionBuilder saveDiagnosis(String patientUuid, String encounterUuid, String diagnosisUuid,String certainty, int rank) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this to a separate PR

@@ -42,4 +42,10 @@ public class Constants {
public static final String ALLERGY_REACTION_UUID = "162553AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String CODED_ALLERGEN_UUID = "71617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
public static final String SEVERITY_UUID = "1498AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";

//Save Visits
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Save Visits
// Visit Notes

@jayasanka-sack
Copy link
Member

I went through the logs of the test run and this was the error:

{"error":{"message":"[converting class org.openmrs.Visit to org.openmrs.module.webservices.rest.web.representation.CustomRepresentation@35f9a8b9 => converting class org.openmrs.Encounter to org.openmrs.module.webservices.rest.web.representation.CustomRepresentation@7049dae => visitType on class org.openmrs.Encounter => Unknown property 'visitType' on class 'class 

Which means the backend can't convert the response as in the requested format (custom representation). For some reason the provided custom representation for get visit is incorrect.

The correct one should be:

String customRepresentation = "custom:(uuid,display,voided,indication,startDatetime,stopDatetime," +
				"encounters:(uuid,display,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display)))," +
				"patient:(uuid,display)," +
				"visitType:(uuid,name,display)," +
				"attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value)," +
				"location:(uuid,name,display))";
		
return http("Get Visits of Patient")
		.get("/openmrs/ws/rest/v1/visit?patient=" + patientUuid + "&v=" + customRepresentation + "&includeInactive=false");

I just took the above from query params of the /openmrs/ws/rest/v1/visit endpoint in dev3.openmrs.org. I think the this should fix the issue. It wasn't failing earlier for other PRs because there were no encounters.

Comment on lines 37 to 39
.exec(registry.addDrugOrder("#{patient_uuid}", "#{visitUuid}", "#{currentUserUuid}"))
.exec(registry.addVisitNote("#{patient_uuid}", "#{currentUserUuid}"))
.exec(registry.endVisit("#{patient_uuid}"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some pauses to make it realistic. In real world, users takes time to perform actions. Also this may fix the Cannot contain encounters whose dates are after the stop of the visit. error.

Suggested change
.exec(registry.addDrugOrder("#{patient_uuid}", "#{visitUuid}", "#{currentUserUuid}"))
.exec(registry.addVisitNote("#{patient_uuid}", "#{currentUserUuid}"))
.exec(registry.endVisit("#{patient_uuid}"));
.exec(registry.addDrugOrder("#{patient_uuid}", "#{visitUuid}", "#{currentUserUuid}"))
.pause(5)
.exec(registry.addVisitNote("#{patient_uuid}", "#{currentUserUuid}"))
.pause(10)
.exec(registry.endVisit("#{patient_uuid}"));

@jayasanka-sack
Copy link
Member

jayasanka-sack commented Feb 25, 2025

The correct custom representation should be this I guess: The previous error of custom representation is still there, which complains encounters don't have an attribute called visitType. According to our previous custom representations, it was nested incorrectly. However I wonder why it works fine on dev3. Can you try below?

custom:(uuid,encounters:(uuid,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display,person:(display)))),patient:(uuid,uuid),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display),startDatetime,stopDatetime)))

formatted version:

(uuid,encounters:
    (
        uuid,
        encounterDatetime,
        form:(uuid,name),
        location:ref,
        encounterType:ref,
        encounterProviders:
            (
                uuid,
                display,
                provider:(uuid,display,person:(display))
            )
    ),
    patient:(uuid,uuid),
    visitType:(uuid,name,display),
    attributes:
        (
            uuid,
            display,
            attributeType:(name,datatypeClassname,uuid),value),
            location:(uuid,name,display),
            startDatetime,stopDatetime)
        )
)

Update: The failing API call is Get Patient's current visit, which has an incorrect custom representation. Update it with above.
method: public HttpRequestActionBuilder getCurrentVisit(String patientUuid)

@jayasanka-sack jayasanka-sack marked this pull request as ready for review February 25, 2025 09:49
Copy link
Member

@jayasanka-sack jayasanka-sack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting this done @Bawanthathilan ! 🎉

@jayasanka-sack jayasanka-sack merged commit 4e097d7 into openmrs:main Feb 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants